<template>
  <view class="float-ball-icon" hover-class="default-icon-hover" @click="click">
    <icon :type="isWorkBench?'success':'waiting'" :size="48"/>
  </view>
</template>

<script>
export default {
  name: "ball",
  computed: {
    isWorkBench() {
      this.$nextTick(() => {
        const pages = getCurrentPages();
        const currentPage = pages[pages.length - 1];
        const $page = currentPage.$page;
        this.workbench = $page.fullPath === this.workbenchPath;
      })
      return this.workbench
    }
  },
  data() {
    return {
      workbench: false,
      welcomePath: '/pages/welcome/index',
      workbenchPath: '/pages/workbench/index',
    }
  },
  methods: {
    click() {
      uni.switchTab({
        url: this.isWorkBench ? this.welcomePath : this.workbenchPath
      })
    },
  }
}
</script>

<style lang="scss" scoped>
@import "ball";
</style>